{% extends 'basic_app/master.html' %}
{% block tag_left %}
    {% include 'basic_app/tag_left_user.html' %}
{% endblock %}
{% block userinfo %}
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <h2 class="page-header">添加实例页</h2>
        <form class="form-horizontal" action="{{ request.path }}" method="post" onsubmit="return validateForm();">
            <div class="form-group">
                <label class="col-sm-2 control-label">Hostname：</label>
                <div class="col-sm-10">
                    <input type="text" style="width:300px;" class="form-control" name="add_hostname" placeholder="主机名">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">Dbname：</label>
                <div class="col-sm-10">
                    <input type="text" style="width:300px;" class="form-control" name="add_dbname" placeholder="数据库名">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">Ip：</label>
                <div class="col-sm-10">
                    <input type="text" id="onsubmit_ip" style="width:300px;" class="form-control" name="add_ip"
                           placeholder="Ip">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">Port：</label>
                <div class="col-sm-10">
                    <input type="text" id="onsubmit_port" style="width:300px;" class="form-control" name="add_port"
                           placeholder="端口">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">Sid：</label>
                <div class="col-sm-10">
                    <input type="text" style="width:300px;" class="form-control" name="add_sid" placeholder="实例名">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">Conn_string：</label>
                <div class="col-sm-10">
                    <input type="text" style="width:300px;" class="form-control" name="add_conn_string"
                           placeholder="连接串">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">remake：</label>
                <div class="col-sm-10">
                    <input type="text" style="width:300px;" class="form-control" name="add_remake" placeholder="备注">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">类别：</label>
                <div class="col-sm-10" style="width:300px;">
                    <select class="form-control" name="add_type">
                        <option>ORACLE</option>
                        <option>MYSQL</option>
                    </select>
                </div>
            </div>
            <div class="col-sm-10">
                {#                <button type="submit" class="btn ">提交</button>#}
                <div style="text-align:center;vertical-align:middle;"><input type="submit" class="btn" value="提交"></div>
            </div>
        </form>
    </div>
{% endblock %}
{% block script %}
    <script>
        function validateForm() {
            console.log("1111")
            {#var phone_reg = /^1[3|4|5|7|8]\d{9}$/;#}
            {#var memberPass = /^[a-zA-Z0-9_]{6,20}$/;#}
            var ip_reg = new RegExp("^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)($|(?!\.$)\.)){4}$");
            {#var ip_reg = /^1[3|4|5|7|8]\d{9}$/;#}
            var numPass = /^[0-9]+$/;
            {#var dPass = /^[a-zA-Z]+$/#}
            var ip = document.getElementById("onsubmit_ip");
            var port = document.getElementById("onsubmit_port");
            if (ip.value == '' || ip.value == null) {
                alert("请输入ip地址");
                return false;
            }
            if (port.value == '' || port.value == null) {
                alert("请输入端口号");
                port.focus();
                return false;
            }
            if (!ip_reg.test(ip.value)) {
                alert("ip地址格式不正确");
                ip.focus();
                return false;
            }
            if (!numPass.test(port.value)) {
                alert("端口格式不正确");
                port.focus();
                return false;
            }
            return true;
        }
    </script>
{% endblock %}

